package com.heima.article.controller;

import com.heima.article.entity.ApArticle;
import com.heima.article.service.ApArticleService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.article.dtos.ArticleHomeDto;
import com.heima.model.article.dtos.AuthorDto;
import com.heima.model.media.dtos.WmNewsDto;
import com.heima.model.media.dtos.WmNewsResultDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api/v1/article")
public class ArticleController {

    @Autowired
    private ApArticleService apArticleService;

    //保存文章,保存文章内容
    @PostMapping("/save")
    public Long save(@RequestBody WmNewsResultDTO dto){
        return apArticleService.saveApArticle(dto);
    }

    //app加载首页文章
    @PostMapping("/load")
    public ResponseResult load(@RequestBody ArticleHomeDto dto){
        return apArticleService.load(dto, 0);
    }

    //app加载更多文章
    @PostMapping("/loadmore")
    public ResponseResult loadmore(@RequestBody ArticleHomeDto dto){
        return apArticleService.load(dto, 1);
    }

    //app加载最新文章
    @PostMapping("/loadnew")
    public ResponseResult loadnew(@RequestBody ArticleHomeDto dto){
        return apArticleService.load(dto, 2);
    }

}
